// *************************************************************************************************
//
// MK3D Engine
// --------------------------------------
// Copyright (C) 2007-2011 Zeb (mailto: zebbey@gmail.com)
//
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//
// *************************************************************************************************

#ifndef __H_MK_D3D9_HARDWARE_BUFFER__
#define __H_MK_D3D9_HARDWARE_BUFFER__

#include "mk_hardware_buffer.h"

namespace MK3DE
{
	class CD3D9VertexHardwareBuffer : public CHardwareBuffer
	{
	public:
		CD3D9VertexHardwareBuffer();
		~CD3D9VertexHardwareBuffer();

		BOOL Create(DWORD vertexSize, DWORD vertexNum, HARDWARE_BUFFER_USAGE usage);

		LPDIRECT3DVERTEXBUFFER9 GetD3D9VertexBuffer() { return _d3dVertexBuffer; }

	public:
		BOOL Lock(void*& pBuffer, DWORD offset, DWORD size, LOCK_OPTION option);
		BOOL Unlock();
		DWORD GetStride() { return _vertexSize; }
		DWORD GetSize()   { return _vertexNum;  }

	private:
		LPDIRECT3DVERTEXBUFFER9 _d3dVertexBuffer;
		DWORD _vertexSize;
		DWORD _vertexNum;
	};

	class CD3D9IndexHardwareBuffer : public CHardwareBuffer
	{
	public:
		CD3D9IndexHardwareBuffer();
		~CD3D9IndexHardwareBuffer();

		BOOL Create(DWORD indexNum, INDEX_TYPE indexType, HARDWARE_BUFFER_USAGE usage);

		LPDIRECT3DINDEXBUFFER9 GetD3D9IndexBuffer() { return _d3dIndexBuffer; }

	public:
		BOOL Lock(void*& pBuffer, DWORD offset, DWORD size, LOCK_OPTION option);
		BOOL Unlock();
		DWORD GetStride() { return _stride;    }
		DWORD GetSize()   { return _vertexNum; }

	private:
		LPDIRECT3DINDEXBUFFER9  _d3dIndexBuffer;
		DWORD _stride;
		DWORD _vertexNum;
	};
};

#endif // __H_MK_D3D9_HARDWARE_BUFFER__